package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdong.pojo.TbUser;
import com.dongdong.pojo.TbUserExample;
import com.dongdong.service.TbUserService;
import com.dongdongshop.mapper.TbUserMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
@org.springframework.stereotype.Service
public class TbUserServiceImpl implements TbUserService {

    @Autowired
    private TbUserMapper userMapper;

    @Override
    public TbUser selectName(String username) {
        TbUserExample example = new TbUserExample();
        TbUserExample.Criteria criteria = example.createCriteria();
        criteria.andUsernameEqualTo(username);
        List<TbUser> tbUsers = userMapper.selectByExample(example);
        if(tbUsers == null || tbUsers.size() <= 0){
            return null;
        }
        return tbUsers.get(0);
    }

    @Override
    public void insertAll(TbUser user) {
        int i = userMapper.insertSelective(user);
    }
}
